import request from '@/utils/request'

// 频道
export const getChannels = () => request.get('/v1_0/channels')

export const getArticles = params => request.get('/v1_0/articles', { params })

export const getDetail = id => request.get(`/v1_0/articles/${id}`)

// export const giveLike = data => request.get('/v1_0/article/likings', data)

// // 文章点赞
// export const updateLike = id => request.delete(` /v1_0/article/likings/${id}`)

// 文章点赞
export const likeArticle = (articleId, isLike) => {
  if (isLike) {
    return request({
      url: '/v1_0/article/likings',
      method: 'post',
      data: { target: articleId }
    })
  } else {
    return request({
      url: '/v1_0/article/likings/' + articleId,
      method: 'delete'
    })
  }
}

// 获取评论
export const getComment = params => request.get('/v1_0/comments', { params })
